package br.uece.laconi.tac.fuzzy;

import br.uece.laconi.tac.fuzzy.functions.*;


public class FuzzySet {
	
	protected GenericFunction membershipFunction = null;
	
	public FuzzySet(GenericFunction mFunc) {
		this.membershipFunction = mFunc;
	}
	
	public Float membershipDegree(FuzzyNumber num) {
		float r = Float.MIN_VALUE;
		for (float i = num.interval[0]; i <= num.interval[1]; i += num.step) {
			r = Math.max(r, Math.min(membershipFunction.calculate(i), num.membershipDegree(i)));
		}
		return r;
	}
	/*
	public Float membershipDegree(CrispFuzzyNumber num) {
		return membershipDegree(num.value);
	}
	*/
	public Float membershipDegree(Float num) {
		return membershipFunction.calculate(num);
	}
}